home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disk User Volume 3 #7 / Commodore_Disk_User_Vol.3_7_1990_-.d64 / maze generator (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  4KB  |  138 lines

  1. 10 poke 53280,0:poke 53281,11
  2. 20 x=x+1
  3. 30 if x=1 then print"[147]loading machine code....":load"maze.mc",8,1
  4. 100 gosub 10000
  5. 110 print"[147][208]ause for thought...":gosub 2080
  6. 120 gosub 1000
  7. 130 if n=42 and di=5 then 30000
  8. 140 on g gosub 2000
  9. 150 if ea=1 then print"[147][197]aten !!":goto 30010
  10. 160 goto 120
  11. 170 j1=peek(56320):if j1<>127 then j=j1
  12. 1000 j1=peek(56320):if j1<>127 thenj=j1
  13. 1010 u=j=126:d=j=125:l=j=123:r=j=119
  14. 1020 o=me:gosub 1500
  15. 1030 n=peek(m)
  16. 1040 if n<>32 and n<>90 and n<>42 then 1090
  17. 1050 if n=42 and di<5 then 1090
  18. 1060 me=m:poke o,32
  19. 1070 if n=90 then di=di+1:poke 1955,di+48
  20. 1080 if di=5 and n=90 then print"[144]go.for.the.exit!!!!";
  21. 1090 if ch=87 then ch=81:goto 1110
  22. 1100 ch=87
  23. 1110 poke me+54272,14:poke me,ch
  24. 1120 return
  25. 1500 m=me+l-r+u*40-d*40:return
  26. 2000 q=q-1:if q<0 then q=3
  27. 2010 w=peek(po+t(q))
  28. 2020 if w=32 or w=90 then 2060
  29. 2030 if w=81 or w=87 then ea=1:goto 2060
  30. 2040 if q<3 then q=q+1: goto2010
  31. 2050 q=0:goto 2010
  32. 2060 poke po,z:po=po+t(q):poke po+54272,0:z=peek(po):poke po,43
  33. 2070 return
  34. 2080 print""
  35. 2090 sys 52600,0,18,10,0,0,88:print"-diamonds: 0-"chr$(142)
  36. 2100 for co=1 to 5
  37. 2110 p=1065+int(rnd(1)*19)*2+int(rnd(1)*10)*80
  38. 2120 poke p,90:poke 54272+p,0
  39. 2130 next
  40. 2140 me=1025:di=0:ch=81:ea=0
  41. 2150 t(1)=-40:t(3)=40:t(2)=-1:t(0)=1
  42. 2160 po=1901:z=32:s=5
  43. 2170 poke 1941,42
  44. 2180 return
  45. 10000 print"[147][205]aze [196]emo"
  46. 10010 print"[183][183][183][183][183][183][183][183][183]"
  47. 10020 print"[212]his machine code program constructs"
  48. 10030 print"rectangular mazes depending on"
  49. 10040 print"specified dimensions. [193]s it is in"
  50. 10050 print"machine code, it is very fast."
  51. 10060 print"[212]ypically a full screen size maze will"
  52. 10070 print"take less than a second to design."
  53. 10080 print"[194]efore starting the maze, you will"
  54. 10090 print"need to say which page in memory the"
  55. 10100 print" maze is to be placed. [193] default"
  56. 10110 print" position '0' will automatically put"
  57. 10120 print" the maze at the end of [194][193][211][201][195] memory."
  58. 10130 print"[217]ou will also need to state the"
  59. 10140 print" horizontal and vertical dimensions"
  60. 10150 print" as well as the [216],[217] coordinates on"
  61. 10160 print" screen (this makes no difference on a"
  62. 10170 print" printer).
  63. 10180 [141] 20000
  64. 10190 [153]"load(NULL)aze str$emo"
  65. 10200 [153]" usrusrusrusrusrusrusrusrusr"
  66. 10210 [153]"(NULL)he syntax for the (NULL)aze program is:"
  67. 10220 [153]" (NULL)(NULL)(NULL) 52600,(NULL)age,left$orizontal,(NULL)ertical,"
  68. 10230 [153]" (NULL) (NULL)osition (0-39),(NULL) (NULL)osition (0-24),"
  69. 10240 [153]" lenharacter (e.g. '65' for 'a' '88'='x')"
  70. 10250 [153]"0,0 for (NULL),(NULL) is the top-left of screen"
  71. 10260 [153]"(NULL)o print a duplicate of a maze, the"
  72. 10270 [153]" syntax is:"
  73. 10280 [153]"(NULL)(NULL)(NULL) 53010,(NULL) (NULL)os,(NULL) (NULL)os,lenharacter"
  74. 10290 [153]"(NULL)ou may prefer to define these:"
  75. 10300 [153]"(NULL)(NULL)=52600 : (NULL)(NULL)=53010 and use (NULL)(NULL)(NULL) (NULL)(NULL),.."
  76. 10310 [153]"to save remembering those addresses."
  77. 10320 [141] 20000
  78. 10330 [153]"load(NULL)aze str$emo"
  79. 10340 [153]"usrusrusrusrusrusrusrusrusr"
  80. 10350 [153]"atn full screen size maze has 18,10"
  81. 10360 [153]" as left$orizontal/vertical dimensions."
  82. 10370 [153]" (NULL)he minimum is 1,1 and maximum left$oriz"
  83. 10380 [153]" dimension is 63 (this is often"
  84. 10390 [153]" too big for most printers anyway!)"
  85. 10400 [141] 20000
  86. 10410 [153]"load(NULL)aze str$emo"
  87. 10420 [153]"usrusrusrusrusrusrusrusrusr"
  88. 10430 [153]"(NULL)ry some mazes:"
  89. 10440 [133] "left$oriz,(NULL)ert:     18,10cmdcmdcmdcmdcmdcmdcmd";h,v
  90. 10450 [139] h[177]18 [167] h[178]18
  91. 10460 [139] h[179]1 [167] h[178]1
  92. 10470 [139] v[177]10 [167] v[178]10
  93. 10480 [139] v[179]1 [167] v[178]1
  94. 10490 [133] " (NULL),(NULL) (NULL)osition:   0,0cmdcmdcmdcmdcmd";x,y
  95. 10500 [139] x[177]39 [167] x[178]39
  96. 10510 [139] x[179]0 [167] x[178]0
  97. 10520 [139] y[179]0 [167] y[178]0
  98. 10530 [139] y[177]24 [167] y[178]24
  99. 10540 [133] " lenharacter:      255cmdcmdcmdcmdcmd";c
  100. 10550 c[178][182](c):[139] c[177]255 [167] c[178]255
  101. 10560 [139] c[179]33 [167] c[178]33
  102. 10570 [141] 20000:[153]"load(NULL)hinking...."
  103. 10580 [158] 52600,0,h,v,x,y,c
  104. 10590 [133]"atnnother maze  yes (NULL).(NULL).cmdcmdcmdcmdcmdcmdcmdcmdcmdcmd";k$
  105. 10600 [139] [200](k$,1)[178]"y" [167] 10410
  106. 10610 [153]"load(NULL)aze str$emo"
  107. 10620 [153]"usrusrusrusrusrusrusrusrusr"
  108. 10630 [153]"(NULL)he mazes can be printed on a printer"
  109. 10640 [153]"by:"
  110. 10650 [153]"(NULL)(NULL)val(NULL) 4,4:len(NULL)str$ 4:(NULL)(NULL)(NULL) 52600,...."
  111. 10660 [153]"(NULL)rint#4:close 4
  112. 10670 print"[217]ou can also change the pitch and"
  113. 10680 print" size beforehand if your printer can do"
  114. 10690 print" this. [214]ery small character sizes give"
  115. 10700 print" some very tricky mazes!"
  116. 10710 gosub 20000
  117. 10720 print"[147][205]aze [196]emo"
  118. 10730 print"[183][183][183][183][183][183][183][183][183]"
  119. 10740 print"[201] have written a little game to show"
  120. 10750 print" one possible use of the routine. [217]ou"
  121. 10760 print" must collect the five black diamonds"
  122. 10770 print" around the maze then head for the exit"
  123. 10780 print" (an asterisk at the bottom-right of"
  124. 10790 print" the maze.)"
  125. 10800 print"[195]ontrol is via [202]oystick in [208]ort [201][201]."
  126. 10810 print" [217]ou can also have a little meanie to"
  127. 10820 print" avoid if you want ('+')."
  128. 10830 input "[196]o you want this  yes please![157][157][157][157][157][157][157][157][157][157][157][157][157]";k$
  129. 10840 if left$(k$,1)="y" then g=1
  130. 20000 print"[208]ress a [203]ey....";
  131. 20010 get k$:if k$="" then 20010
  132. 20020 return
  133. 30000 print"[147][215]ell [196]one !"
  134. 30010 input"[196]o you want to play that again";k$
  135. 30020 if left$(k$,1)="y" then 110
  136. 30030 print"[147][210]emember.....[212]here's only one way      [212]hrough....."
  137. 30040 end
  138.